<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
  <style>
    button {
      margin-right: 10px;
    }
  </style>
</head>

<body>
  <script>
    // JS创建10个<a>标签，点击的时候弹出对应的序号
    for (let i = 1; i <= 10; i++) {
      let a = document.createElement('a');
      a.innerHTML = i + '<br>';
      a.addEventListener('click', function (e) {
        e.preventDefault();
        alert(i);
      })
      document.body.appendChild(a);
    }
  </script>
</body>

</html>